package 公司真题.声网;

import java.util.Scanner;

public class _全部由1组成的数 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // m = m * 10 + 1, until m % n == 0
        int n = sc.nextInt();
        // if (n % 2 == 0 || n % 5 == 0) throw new IllegalArgumentException();
        long m = 1;
        int count = 1;
        while ((m % n) != 0) {
            m = m * 10 + 1;
            count++;
        }
        System.out.println(count);
    }
}
